package cn.edu.zjicm.wordsnet_d.activity.base;

import android.app.ActionBar.LayoutParams;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import cn.edu.zjicm.wordsnet_d.R;
import cn.edu.zjicm.wordsnet_d.util.Utils;

public class BaseNormalActivity extends BaseActivity {
	private FrameLayout mBaseTitle;
	private FrameLayout mBaseContent;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		super.setContentView(R.layout.layout_base_normal);
		findViews();
		initViews();
	}

	private void findViews() {
		mBaseTitle = (FrameLayout) findViewById(R.id.base_title_container);
		mBaseContent = (FrameLayout) findViewById(R.id.base_content_container);
	}

	private void initViews() {

	}

	public void setContentView(View view) {
		if (view != null) {
			mBaseContent.addView(view, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
		} else {
			super.setContentView(view);
		}
	}

	public void setContentView(int layoutId) {
		View view = getLayoutInflater().inflate(layoutId, null);
		setContentView(view);
	}

	/**
	 * 隐藏自定义标题
	 */
	public void hideTitle() {
		mBaseTitle.setVisibility(View.GONE);
	}

	public void showTitle() {
		mBaseTitle.setVisibility(View.VISIBLE);
	}

	public void setTitleView(View view) {
		if (view != null) {
			mBaseTitle.addView(view, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
		}
	}

	public void setTitleView(int layoutId) {
		View view = getLayoutInflater().inflate(layoutId, null);
		setTitleView(view);
	}

	protected void immersionBaseStatusBarForXiaoMi() {
		LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, Utils.changeDipToPx(BaseNormalActivity.this, 70));
		mBaseTitle.setLayoutParams(lp);
	}

}
